﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WpfElevator.ControlPart
{
    class ControllerImpl3 :AController
    {
        public override void addOutsideEvent(AbstractFramework.LogicControl.IEvent inputevent)
        {
            int minTask = 9999;
            int key = 0;
            int temp = 0;


            for (int i = 0; i < elevator.Length; i++)
            {
                if (elevator[i].FbdFloor.Contains(inputevent.floor + 1))
                {

                    continue;
                }
                int j = 0;
                for (; taskList[i].floors[j] != 0; j++) ;
                temp = j;
                if (minTask > j)
                {
                    minTask = j;
                    key = i;
                }
            }
            if (minTask == 9999)
                return;
            eventIntoList(key, inputevent);
            updateTask(key, taskList[key].floors[0]);
            return;
        }
    }
}
